Improve clarity of next('route') usage in Route Handlers section #2034
+20
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This PR adds a concrete example demonstrating the use of next('route') in the “Route handlers” section of the Express routing documentation.
Currently, the docs mention next('route') but don’t show a simple, self-contained example, which could make it unclear for new users. This change:
Adds a GET /user/:id example that uses next('route') to skip to the next matching route.
Includes a short bullet-point explanation of the behavior for two different request paths (/user/5 and /user/0).
Before:
The section explains next('route') but doesn’t show a minimal code sample demonstrating it in action.
After:
The section now contains:
In this example:
GET /user/5 → handled by first route → sends "User 5"
GET /user/0 → first route calls next('route'), skipping to the next matching /user/:id route
Why this change improves the docs:
Makes the next('route') behavior obvious without requiring guesswork.
Matches the style and tone of existing Express documentation.
Adds a practical example to complement the textual explanation.